<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
	<div data-type="layout" data-defs="fit:true">
		<div
			data-defs="region:'center',title:'#springMessage('resourceInfo')',border:false,bodyCls:'byr',headerCls:'byb byr',split:true">
			<ul id="resourcemanage_resourceTree" data-type="tree" style="padding: 2px"
				data-defs="
					method:'post',border:true,
					onClick : tree1OnClickFun,
					url:'${rc.contextPath}/admin/getResource.do',
					animate:false,dnd:false"></ul>
		</div>
		<div data-defs="region:'east',split:true,border:false,bodyCls:'byr byl',headerCls:'byb byl'"
			title="#springMessage('resourceInfoDetail')" style="width: 600px;">
			<form id="resourcemanage_resourceForm" method="post">
				<table class="stable" cellpadding="1" cellspacing="1" style="width: 100%">
					<input type="hidden" name="resourceId"></input>
					<tr>
						<!-- 父节点 -->
						<td width="25%" class="stdlabel">#springMessage("parentResourceName")</td>
						<td width="75%" class="stdinput">
							<input data-type="combotree" type="text" name="parentResourceId"
								data-defs="url: '${rc.contextPath}/admin/getResource.do?onlyPageResource=1',
								method:'post',required:false"></input>
						</td>
					</tr>
					<tr>
						<!-- 资源名称-->
						<td width="25%" class="stdlabel">#springMessage("resourceName")</td>
						<td width="75%" class="stdinput">
							<input data-type="inputbox" type="text" name="resourceName" data-defs="required:true,tipPosition:'left'"></input>
						</td>
					</tr>
					<tr>
						<!--资源地址-->
						<td width="25%" class="stdlabel">#springMessage("resourceUrl")</td>
						<td width="75%" class="stdinput">
							<input data-type="inputbox" type="text" name="resourceUrl" data-defs="required:true,tipPosition:'left'"></input>
						</td>
					</tr>
					<tr>
						<!--资源类型 -->
						<td width="25%" class="stdlabel">#springMessage("resourceType")</td>
						<td width="75%" class="stdinput">
							<input data-type="combobox"
								data-defs="editable:false,required:true,url:'${rc.contextPath}/getCombo.do?codeId=2',tipPosition:'left'"
								type="text" name="resourceType"></input>
						</td>
					</tr>
					<tr>
						<!-- 应用标志 -->
						<td width="25%" class="stdlabel">#springMessage("usedFlag")</td>
						<td width="75%" class="stdinput">
							<input data-type="combobox" type="text" name="usedFlag"
								data-defs="editable:false,required:true,tipPosition:'left',url:'${rc.contextPath}/getCombo.do?codeId=3'"></input>
						</td>
					</tr>
					<tr>
						<!-- 排序号 -->
						<td width="25%" class="stdlabel">#springMessage("orderNum")</td>
						<td width="75%" class="stdinput">
							<input data-type="numberbox" type="text" name="orderNum" data-defs="required:true,tipPosition:'left'"></input>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<div style="margin: 0px 0; padding-top: 5px;" align="center">
								<a id="resourcemanage_clearButton" href="#" data-type="button" data-defs="iconCls:'icon-clear'">
									#springMessage("buttonClear") </a>
								<a id="resourcemanage_clearParentButton" href="#" data-type="button" data-defs="iconCls:'icon-clear','width':100">
									#springMessage("buttonClearParent") </a>
								<a id="resourcemanage_saveButton" href="#" data-type="button" data-defs="iconCls:'icon-save'">
									#springMessage("buttonSave") </a>
								<a id="resourcemanage_deleteButton" href="#" data-type="button" data-defs="iconCls:'icon-delete'">
									#springMessage("buttonDelete") </a>
							</div>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
	<script type="text/javascript">
		function tree1OnClickFun(node) {
	        $("#resourcemanage_resourceForm").form('clear');
	        var url = "${rc.contextPath}/admin/getReourceDetail.do?resourceId=" + node.id;
	        $("#resourcemanage_resourceForm").form('load', url);
        }
        $(document).ready(function() {
	        $("#resourcemanage_clearButton").bind("click", function() {
		        $("#resourcemanage_resourceForm").form('clear');
	        });
	        $("#resourcemanage_saveButton").bind("click", function() {
		        var url = "${rc.contextPath}/admin/saveReource.do";
		        var v = $("#resourcemanage_resourceForm").form('validate');
		        if (!v) {
			        return;
		        }
		        submitForm("resourcemanage_resourceForm", url, function(rs) {
			        var returnedObj = $.parseJSON(rs);
			        showMsg(returnedObj.msgInfo);
			        $("#resourcemanage_resourceForm").form('load', {
				        "resourceId" : returnedObj.data
			        });
			        $('#resourcemanage_resourceTree').tree("reload");
		        });
	        });
	        $("#resourcemanage_clearParentButton").bind("click", function() {
		        var url = "${rc.contextPath}/admin/saveReourceParentNull.do";
		        var resourceId = $("[name='resourceId']", $("#resourcemanage_resourceForm")).val();
		        if (resourceId == null || resourceId == "") {
			        showMsg('#springMessage("unSelectedMsg")');
			        return;
		        }
		        submitForm("resourcemanage_resourceForm", url, function(rs) {
			        var returnedObj = $.parseJSON(rs);
			        showMsg(returnedObj.msgInfo);
			        $("#resourcemanage_resourceForm").form('load', {
			            "resourceId" : returnedObj.data,
			            "parentResourceId" : ""
			        });
			        $('#resourcemanage_resourceTree').tree("reload");
		        });
	        });
	        $("#resourcemanage_deleteButton").bind("click", function() {
		        confirmMsg('#springMessage("confirmDelete")', function(r) {
			        if (r) {
				        var url = "${rc.contextPath}/admin/deleteReource.do";
				        var resourceId = $("[name='resourceId']", $("#resourcemanage_resourceForm")).val();
				        if (resourceId == null || resourceId == "") {
					        showMsg('#springMessage("unSelectedMsg")');
					        return;
				        }
				        submitForm("resourcemanage_resourceForm", url, function(rs) {
					        var returnedObj = $.parseJSON(rs);
					        showMsg(returnedObj.msgInfo);
					        if (returnedObj.msgType == "1") {
						        $("#resourcemanage_resourceForm").form('clear');
					        }
					        $('#resourcemanage_resourceTree').tree("reload");
				        });
			        }
		        });
	        });
        });
	</script>
</body>
</html>